   <#include
"../common/com.html"/> <@layout>
   	
<!-- ace styles -->
<link rel="stylesheet" href="${ctx}/static/assets/css/ace.min.css" />

<link rel="stylesheet" href="${ctx}/static/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="${ctx}/static/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="${ctx}/static/kindeditor/lang/zh_CN.js"></script>
<script charset="utf-8" src="${ctx}/static/kindeditor/plugins/code/prettify.js"></script>

<script type="text/javascript">
    /**
     * 新增
     */
    function saveModel() {
        var id=document.getElementById("id").value;
              if(Validator.Validate(document.getElementById('form1'))){
        } else {
            return;
        }
        
        // 拼接checkbox
        var levle_checkbox = "";
        $('input[name="level_checkbox"]:checked').each(function(){    
        	 levle_checkbox += $(this).val();
        	 levle_checkbox += ",";
        });
        if(levle_checkbox!="") levle_checkbox = levle_checkbox.substr(0,levle_checkbox.length-1);
        $("#level").val(levle_checkbox);
              
        url = '';
        if(id==""){
            url = '${ctx}/tbMeetTeacher/save';
        }     else{
            url = '${ctx}/tbMeetTeacher/update';
        }
        $('#form1').form('submit', {
            url : url,
            onSubmit : function() {
                return $(this).form('validate');
            },
            success : function(data) {
                alert(data);
                parent.location.reload();
                //window.location.href=' ${ctx}/tbMeetTeacher';
            }
        });

    }
</script>
<div class="page-content">
<div class="row-fluid">
						<div class="span12">
                <form class="form-horizontal"  id="form1" method="post" enctype="multipart/form-data">
                	<input type="hidden"  name="id" id="id"    >
								 								<div class="control-group">
									<label class="control-label">姓名:</label>
						<div class="controls"> <input id="name"
								name="name" type="text" dataType="Require" msg="请输入姓名"
								 dataType="Require" msg="请输入姓名"  style="min-height: 24px;"  />
							</div>
								 	</div>
								  								<div class="control-group">
									<label class="control-label">手机号:</label>
						<div class="controls"> <input id="tel"
								name="tel" type="text"
								  style="min-height: 24px;"  />
							</div>
								 	</div>
								  								<div class="control-group">
									<label class="control-label">email:</label>
						<div class="controls"> <input id="email"
								name="email" type="text"
								  style="min-height: 24px;"  />
							</div>
								 	</div>
								  								<div class="control-group">
									<label class="control-label">生日:</label>
						<div class="controls"> <input id="birth"
								name="birth" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"
								  style="min-height: 24px;"  />
							</div>
								 	</div>
						
						<div class="control-group">
									<label class="control-label">级别：</label>
						<div class="controls"> 
						
						<input type="hidden" id="level" name="level" >
						
						<label class="checkbox inline">
						  <input type="checkbox" name="level_checkbox" id="level1" value="1">主讲
						</label>
						<label class="checkbox inline">
						  <input type="checkbox"  name="level_checkbox" id="level2" value="2">宣讲
						</label>
							</div>
						</div>
						
						<div class="control-group">
									<label class="control-label">照片:</label>
						<div class="controls"> 
						<#-- 
						<input id="img" name="img" type="text"  style="min-height: 24px;"  />
						-->
						<img style="float: left;" id="show_img" alt="图片" title="点击浏览" src="" width="40" height="40">
						
						<input style="float: left;margin-left: 10px;" class="form-control" 
								accept="image/png,image/gif,image/jpeg"
								type="FILE" id="img" name="img"  />
							</div>
						</div>
						
						<div class="control-group">
									<label class="control-label">简介:</label>
						<div class="controls"> 
						<textarea class="span12"  id="content" name="content" style="width:70%;height:180px;visibility:hidden;"></textarea>
						<#-- 
						<input id="content" name="content" type="text" style="min-height: 24px;"  />
						 -->
							</div>
						</div>

    
             </form>
        </div>
        	<div class="span12 center">
				<a  class="btn btn-info btn-small" onclick="saveModel()">确定
				<a href="#"  class="btn btn-danger btn-small bigger-110"  onclick="parent.closeDialog();"  >取消 </a>
		</div>
    </div>
</div>

    </body>

<script>
    KindEditor.ready(function(K) {
        K.each({
            'plug-align' : {
                name : '对齐方式',
                method : {
                    'justifyleft' : '左对齐',
                    'justifycenter' : '居中对齐',
                    'justifyright' : '右对齐'
                }
            },
            'plug-order' : {
                name : '编号',
                method : {
                    'insertorderedlist' : '数字编号',
                    'insertunorderedlist' : '项目编号'
                }
            },
            'plug-indent' : {
                name : '缩进',
                method : {
                    'indent' : '向右缩进',
                    'outdent' : '向左缩进'
                }
            }
        },function( pluginName, pluginData ){
            var lang = {};
            lang[pluginName] = pluginData.name;
            KindEditor.lang( lang );
            KindEditor.plugin( pluginName, function(K) {
                var self = this;
                self.clickToolbar( pluginName, function() {
                    var menu = self.createMenu({
                        name : pluginName,
                        width : pluginData.width || 100
                    });
                    K.each( pluginData.method, function( i, v ){
                        menu.addItem({
                            title : v,
                            checked : false,
                            iconClass : pluginName+'-'+i,
                            click : function() {
                                self.exec(i).hideMenu();
                            }
                        });
                    })
                });
            });
        });
        editor =  K.create('#content', {
            cssPath : '${ctx}/static/kindeditor/plugins/code/prettify.css',
            uploadJson : '${ctx}/uploadWxfile/upload/',
            fileManagerJson : '${ctx}/uploadWxfile/manageImg',
            allowFileManager : true,
            themeType : 'default',
            filterMode : true,
            items :[
                'source', //'|', 'undo', 'redo', 
                //'|', 'preview', 'print', 'template', 'paste', 'plainpaste', 'wordpaste',
                 '|', 'justifyleft', 'justifycenter', 'justifyright', // 'justifyfull',
                 'insertorderedlist',// 'insertunorderedlist', 'indent', 'outdent',
                //'clearhtml', 'quickformat', 'selectall', '|',
                // 'formatblock', 'fontname', 'fontsize', '|', //'/',
                'forecolor', 'hilitecolor', 'bold',
                'italic', 'underline', //'strikethrough', 'lineheight', 'removeformat', '|',
                //'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak','anchor',
                 'link'//, 'unlink', '|', 'image'//, 'multiimage'
            ] ,
            afterBlur:function(){this.sync(); }
        });

    });
</script>
   
    <script>
    	 /**
    * 修改页面使用
    */
  $(function(){
 <#list newlist as m>
	    document.getElementById("id").value  
	    =  '${(m.id)!}'; 
        document.getElementById("name").value  
        =  '${(m.name)!}';
        document.getElementById("tel").value  
        =  '${(m.tel)!}';
        document.getElementById("email").value  
        =  '${(m.email)!}';
        document.getElementById("birth").value  
        =  '${(m.birth)!}';
        document.getElementById("level").value  
        =  '${(m.level)!}';
        document.getElementById("content").value  
        =  '${(m.content)!}';
        
        <#if m.img==''>
        $("#show_img").attr("src"," ${ctx}/uploadfile/teacher/default.png");
        <#else>
        $("#show_img").attr("src","${ctx}/uploadfile/teacher/${(m.img)!}");
        </#if>
</#list>

	// 设置level被选中
	var level = $('#level').val();
	if(level != "" ){
		levelArr = level.split(',');
		for(var i=0;i<levelArr.length;i++){
			$("#level"+levelArr[i]).attr("checked","checked"); 
		}
	}

  });
    </script>
 </@layout> 
